﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>复选框全选（一）</title>
    <script language="JavaScript">
        function SelectAll(){
            oE = event.srcElement;
            for(i = 0;i< document.all.length;i++){
                if(document.all(i).id.indexOf("Checkbox")!=-1){
                    if(oE.checked){
                        document.all(i).checked = true;
                    }else{
                        document.all(i).checked = false;
                    }
                }
            }
        }
    </script>
</head>
<body>
<input id="Checkbox1" type="checkbox" value="a" /><label >争取举办奥运会的城市</label><br />
<input id="Checkbox2" type="checkbox"  value="b"/><label >举办过奥运会的城市</label><br />
<input id="Checkbox3" type="checkbox"value="c" /><label >成功举办奥运会的城市</label><br />
<input id="Checkbox4" type="checkbox" value="d" /><label >亚洲举办过奥运会的城市</label><br />
<input id="Checkbox5" type="checkbox"  onclick="SelectAll()"/>全选或全不选</body>
</html>